package com.qf.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsRegionMapper;
import com.qf.pojo.DtsRegion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.security.interfaces.RSAKey;

@Service
public class RegionServiceImpl implements RegionService {

    @Autowired
    private DtsRegionMapper regionMapper;

    @Override
    public IPage<DtsRegion> queryAllRegion(String name,String code,Integer page, Integer limit) {

        IPage<DtsRegion> ipage = new Page<>(page, limit);
        QueryWrapper<DtsRegion> queryWrapper = new QueryWrapper<>();
        if (!StringUtils.isEmpty(name)){
            queryWrapper.eq("name",name);
        }
        if (!StringUtils.isEmpty(code)){
            queryWrapper.eq("code",code);
        }

        IPage<DtsRegion> resultPage = regionMapper.selectPage(ipage, queryWrapper);


        return resultPage;
    }
}
